<template>
	<view class="list">
		<view class="item" v-for="(item, index) in menuList" :key="index" @click="ShowItems(item.id, index)">
			<image :src="item.navpic" mode=""></image>
			<text class="menuname">{{ item.name }}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuList: [],
				
			}
		},
		mounted() {
			this.getMenuList()
		},
		methods: {
			// 获取所有导航按钮
			async getMenuList() {
				let all = []
				let res = await this.$Request("POST", "/Index/homepage",{})
				  // console.log(res);
				all = res.data.data
				this.menuList = all.slice(0,8)
				this.$store.commit("getNavbar", all)
			},
			// 展示导航页面
			ShowItems(id, index) {
				uni.navigateTo({
					url: `/pages/menu/menu?menuid=${id}`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 20rpx;
		box-sizing: border-box;
		.item {
			display: flex;
			width: 160rpx;
			height: 160rpx;
			flex-direction: column;
			align-items: center;
			image {
				width:60rpx;
				height: 60rpx;
			}
			.menuname {
				margin-top: 10rpx;
			}
		}
	}
</style>
